package com.fu.jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author 付大大
 * @description
 * @create 2021-01-31 11:13
 */
public class MyDataSourceTest {
    public static void main(String[] args) throws SQLException {
        MyDataSource myDataSource = new MyDataSource();

        System.out.println(myDataSource.getSize());

        Connection connection = myDataSource.getConnection();
        System.out.println(connection.getClass());


        String sql = "select * from student";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);

        ResultSet resultSet = preparedStatement.executeQuery();

        while (resultSet.next()) {
            System.out.println(resultSet.getInt("sid") + "\t" + resultSet.getString("name") + "\t"
                    + resultSet.getInt("age") + "\t" + resultSet.getDate("birthday"));
        }

        resultSet.close();
        preparedStatement.close();
        connection.close();

        System.out.println(myDataSource.getSize());
    }
}
